package labox.innovation.gameserver.network.clientpackets;

import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.network.serverpackets.ClientScriptHandle;
import labox.innovation.gameserver.templates.skills.L2EffectType;

/**
 * 
 * 客户端请求 结束某个效果
 * 只能结束buff效果
 * @author zjj
 *
 */
public class RequestStopEffect extends L2GameClientPacket {

	private static final String RequestEffectBuff = "[C] 0x58 RequestEffectBuff";
	
	//技能Id 和 效果类型 能唯一的确定一个效果
	private int _skillid;      //技能id
	private int _effectType;   //效果类型
	
	@Override
	public String getType() {
		return RequestEffectBuff;
	}

	@Override
	protected void readImpl() {
		_skillid = readInt();
		_effectType = readByte();
		
	}

	@Override
	protected void runImpl() {
		
		FuzePcInstance pc = getClient().getActiveChar();
		if( pc == null )
		{
			return;
		}
		
		if( pc.getEffectList() == null )
		{
			return;
		}
		
//		System.out.println("客户端请求结束某个效果");
//		System.out.println("技能Id:" + _skillid );
//		System.out.println("技能效果类型:" + _effectType );
		
		if( pc.getEffectList().stopBuffEffect( _skillid, L2EffectType.values()[_effectType]) )
		{
			String effectStr = "remove(" + "\"" +_skillid + "*" + _effectType + "\""+ ")";
//			System.out.println("发送效果状态更新消息:" + effectStr);
			pc.sendPacket( new ClientScriptHandle("state", effectStr) );
		}

	}

}
